package com.rs.service.impl.rs;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rs.dao.ItemsRecipientsMapper;
import com.rs.model.CommonResult;
import com.rs.model.ItemsRecipients;
import com.rs.service.rs.RecipientsService;

@Service
public class RecipientsServiceImpl implements RecipientsService {

	@Autowired
	private ItemsRecipientsMapper rd;

	//查看所有物品领用申请
	@Override
	public CommonResult<Map<String, Object>> recipientsAllPC(ItemsRecipients items) {
		Page<ItemsRecipients> page = PageHelper.startPage(items.getPageNum(), 10);//分页
		List<ItemsRecipients> list = rd.recipientsAllPC(items);

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", list);
		map.put("total", page.getTotal());
		map.put("pages", page.getPages());
		map.put("pageNum", page.getPageNum());
		return new CommonResult<Map<String, Object>>(200, "查询成功", map);
	}

	//根据ID查询物品领用
	@Override
	public ItemsRecipients recipientsByIdPC(Integer id) {

		return rd.recipientsByIdPC(id);
	}

	//修改物品领用申请内容
	@Override
	public int recipientsUpdatePC(ItemsRecipients itre) {
		itre.setIt_audit(0);
		return rd.recipientsUpdatePC(itre);
	}

	//添加申请
	@Override
	public int recipientsAddPC(ItemsRecipients itre) {
		itre.setIt_audit(0);
		return rd.recipientsAddPC(itre);
	}

	//删除申请
	@Override
	public int recipientsDelPC(ItemsRecipients itre) {

		return rd.recipientsDelPC(itre);
	}

	//App端查询所有
	@Override
	public List<ItemsRecipients> recipientsAllApp() {
		return rd.recipientsAllApp();
	}

	//添加申请App
	@Override
	public int recipientsAddApp(ItemsRecipients itre) {
		itre.setIt_audit(0);
		return rd.recipientsAddApp(itre);
	}

	//修改申请物品领用内容App
	@Override
	public int recipientsUpdateApp(ItemsRecipients itre) {
		itre.setIt_audit(0);
		return rd.recipientsUpdateApp(itre);
	}

	//删除申请App
	@Override
	public int recipientsDelApp(ItemsRecipients itre) {
		return rd.recipientsDelApp(itre);
	}

	@Override
	public void recipientsToExamine(ItemsRecipients itre) {
		// TODO Auto-generated method stub
		rd.recipientsUpdatePC(itre);
	}
}
